In an object-oriented programming language, such as C++, a class template defines the layout and operations for unbounded sets of related types. Templates provide a strongly-typed "macro" facility, and promote source code re-use. For example, a single class template for a stack might provide a common definition for a stack of integers, a stack of floats, or a stack of pointers to char strings. A template may be used by an individual program to implement an object, such as a stack. Rather than writing code to implement the stack, the programmer can simply use a stack template. Thus, templates reduce the amount of source code that programmers need to write, and promote code reuse.
The problem with the implementation of templates is that while the object code for different template class declarations may be similar, or even identical, the object code is not reused, where possible, for each different template class declaration. This means that every time a programmer defines and uses a different stack class, the template code is inserted into the program. This results in duplicate code being included in the program.
Consequently, it would be desirable to have a system and method for reusing code, where possible, to reduce the size of the program. It would also be desirable to have a system and method for reusing code which would have a negligible impact on the efficiency of the code.